﻿using AntdUI;

namespace DataAcquisition
{
    public partial class BaseForm : Window
    {
        #region 属性
        /// <summary>是否全屏
        /// 
        /// </summary>
        public bool FullScreen { get; set; }

        #endregion

        #region 自定义方法

        /// <summary>Success消息
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public void Success(string msg)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                AntdUI.Message.success(this, msg, Font, 1);
            }));
        }

        /// <summary>Info消息
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public void Info(string msg)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                AntdUI.Message.info(this, msg, Font, 1);
            }));
        }

        /// <summary>Warn消息
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public void Warn(string msg)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                AntdUI.Message.warn(this, msg, Font, 1);
            }));
        }

        /// <summary>Error消息
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public void Error(string msg)
        {
            this.Invoke(new MethodInvoker(delegate
            {
                AntdUI.Message.error(this, msg, Font, 1);
            }));
        }
        #endregion

        #region 系统方法
        public BaseForm()
        {
            InitializeComponent();
        }
        private void BaseForm_Load(object sender, EventArgs e)
        {
            if (FullScreen)
            {
                if (Screen.PrimaryScreen is not null)
                {
                    Screen primaryScreen = Screen.PrimaryScreen;
                    ScreenRectangle = new Rectangle(0, 0, primaryScreen.WorkingArea.Size.Width, primaryScreen.WorkingArea.Height);
                }
            }
            StartPosition = FormStartPosition.CenterScreen;
        }
        #endregion

        private void BaseForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose();
        }
    }
}
